package org.budo.support.spring.bean.factory.util;

import org.budo.support.spring.bean.util.PropertyValueUtil;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;

import lombok.extern.slf4j.Slf4j;

/**
 * @author lmw
 */
@Slf4j
public class BeanDefinitionUtil {
    public static Object getPropertyValue(BeanDefinition beanDefinition, String propertyName) {
        try {
            MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
            return PropertyValueUtil.get(propertyValues, propertyName);
        } catch (Throwable e) {
            log.error("#19 getPropertyValue, beanDefinition=" + beanDefinition + ", propertyName=" + propertyName + ", e=" + e, e);
            return null;
        }
    }
}